< previous page page_29 next page >

Page 29
e10a6a0a59f035e870d90cca05b85fce.gif
    End If
    If need_vbar Then
        vbarMarble.Move got_wid + border_width, 0, _
            vbarMarble.Width, got_hgt + border_width
        vbarMarble.Min = 0
        vbarMarble.Max = picInner.ScaleHeight - got_hgt
        vbarMarble.SmallChange = got_hgt / 5
        vbarMarble.LargeChange = got_hgt
        vbarMarble.Visible = True
    Else
        vbarMarble.Value = 0
        vbarMarble.Visible = False
    End If
End Sub

' Reposition picInner.
Private Sub hbarMarble_Change()
    picInner.Left = -hbarMarble.Value
End Sub

' Reposition picInner.
Private Sub hbarMarble_Scroll()
    picInner.Left = -hbarMarble.Value
End Sub

' Reposition picInner.
Private Sub vbarMarble_Change()
    picInner.Top = -vbarMarble.Value
End Sub

' Reposition picInner. 
Private Sub vbarMarble_Scroll()
    picInner.Top = -vbarMarble.Value
End Sub
Once it knows which scroll bars it needs, the program positions picOuter and the scroll bars. It then sets the scroll bar properties. It sets each scroll bar's Min property to 0. Remember that the program adjusts picInner's Top and Left property values when the user changes the scroll bar values. When the scroll bars have the value 0, the program sets picInner's Top or Left property to 0. That positions the control in the upper-left corner of picOuter so that the upper-left corner of picInner is visible.
ArrangeControls sets the scroll bar's Max property to the difference between the space needed and the space available. When the program adjusts picInner's Top or Left properties by this amount, the farthest parts of picInner's image are visible.
The program sets the scroll bar's SmallChange values to one fifth of the available space. When the user clicks on a scroll bar's arrows, the program adjusts the position of the image by one fifth of the size of the visible area. This value was chosen somewhat arbitrarily; you could pick a different value.

 
< previous page page_29 next page >